Repository navigation
Conversation
…gine/x client v1.0.0 moves its shared types into the new github.com/docker/secrets-engine/secrets module and no longer depends on github.com/docker/secrets-engine/x. Take the Docker Desktop socket path from client/config instead of x/api, so x is no longer needed. This also drops connectrpc.com/connect and golang.org/x/mod from the binary, which makes docker-compose about 2.2% smaller on linux, darwin and windows. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
…session Docker Desktop can prompt the user before it gives a process access to a realm, and reading the default Docker Hub session reads from two realms, docker/auth/metadata/hub/** and docker/auth/hub/**. The 5 second lookup timeout expired before the user could answer, so the lookup fell back to the Docker CLI credentials. Call Authorize once on docker/auth/**, which covers the production and staging realms, with a one minute timeout, and keep the decision until the expiry Docker Desktop returns. The session reads keep their 5 second timeout. A denied or unanswered authorization falls back to the Docker CLI credentials like any other failed lookup. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
…gine answers Authorize has a one minute timeout, so the user can answer the Docker Desktop prompt. An engine that accepts the connection but never answers looked the same, and delayed the first Docker Hub lookup by a minute. Ask the engine for its version first, within the 5 second lookup timeout, and only then call Authorize. The secrets engine API has no way to say that it is waiting for the user, but the version request is not gated by a prompt: it answered in about 10 ms from a new process. An engine that does not answer now falls back after 5 seconds, as before. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
The version request that comes before Authorize is not gated by a prompt and answered in about 10 ms from Docker Desktop, so it does not need the 5 second lookup timeout. With 1 second, an engine that accepts the connection but does not answer falls back to the Docker CLI credentials after 1 second instead of 5. The session reads keep 5 seconds and Authorize keeps 1 minute. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
f78f847 to
bb8956d
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
Lower-confidence findings (not posted inline)
- [low]
internal/registry/desktop.go:171 —s.authorizednot reset tofalseafter re-authorization fails (confidence: not verified, low severity) - [low]
internal/registry/desktop_test.go:596 —TestDesktopAuthProvider_FallsBackWhenNotAuthorizeddoes not assertpingCalls, leaving retry-on-denied behaviour partially untested (confidence: not verified, low severity)
| validUntil time.Time | ||
| } | ||
|
|
||
| func (s *desktopSession) authorize() error { |
There was a problem hiding this comment.
[medium] Ping timeout surfaces as context.DeadlineExceeded, which isSessionUnavailable doesn't recognise — emits a spurious Warn-level log instead of Debug
When the 1-second ping to the secrets engine times out, s.hub.Ping(pingCtx) returns context.DeadlineExceeded. authorize() wraps it and returns it to auth(), which passes it to logDesktopFallback(). isSessionUnavailable() only matches *seclient.ConnectError, dockerhub.ErrNoSession, and errSessionExpired — none of which match context.DeadlineExceeded — so logDesktopFallback emits a Warn-level message:
could not use the Docker Hub session from Docker Desktop, using Docker CLI credentials instead
instead of the quiet Debug-level message intended for "Desktop is not reachable". This is a user-visible regression: on any machine where the secrets engine is not running (most CI environments, non-Docker Desktop Linux), every Docker Hub credential lookup will log a warning. The existing test TestDesktopAuthProvider_FallsBackWhenTheEngineDoesNotAnswer already exercises context.DeadlineExceeded as a ping error, but doesn't assert the log level.
The fix is to extend isSessionUnavailable to also recognise deadline/timeout errors from the ping path:
func isSessionUnavailable(err error) bool {
if _, ok := errors.AsType[*seclient.ConnectError](err); ok {
return true
}
if errors.Is(err, context.DeadlineExceeded) {
return true
}
return errors.Is(err, dockerhub.ErrNoSession) || errors.Is(err, errSessionExpired)
}| Confidence | Score |
|---|---|
| 🟢 strong | 97/100 |
| return fmt.Errorf("checking the secrets engine: %w", err) | ||
| } | ||
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), s.authorizeTimeout) |
There was a problem hiding this comment.
[medium] authorize() holds s.mu for up to 1 minute while awaiting a user prompt — all concurrent credential lookups are stalled
auth() takes s.mu and holds it for the entire fetch() → authorize() call chain. authorize() creates its Authorize context from context.Background() with a 1-minute ceiling, so it cannot be cancelled by a caller context (e.g., Ctrl+C / SIGINT). If the Desktop prompt is not answered, any concurrent goroutine calling auth() on the same desktopSession (e.g., parallel pulls of multiple images) will block for up to 1 minute.
This is an intentional trade-off (the user needs time to respond to the prompt) and is acknowledged in the PR description as an open item. However, it means that a Docker Compose run with many concurrent pulls can appear completely frozen while one goroutine is waiting for the prompt.
A partial mitigation is to call Authorize before taking the lock (or in a one-shot goroutine guarded by sync.Once) and to store only the result under s.mu. That way concurrent callers either fast-return with the cached decision or wait on the same Authorize call without holding a mutex the whole time.
| Confidence | Score |
|---|---|
| 🟢 strong | 97/100 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Warning
Draft. Depends on #14541, which bumps
github.com/docker/secrets-engine/clientto v1.0.0. Its commit is the first one here; review the last three. Tested against Docker Desktop on macOS with a binary that is not signed by Docker (see Docker Desktop test). Not yet tested with a Docker-signed build, on Linux or Windows, or with the E2E suite.What this PR does
Authorizeondocker/auth/**before reading the Docker Desktop session, so Docker Desktop prompts at most once per process, and gives the user up to 1 minute to answer that prompt. Before this, every lookup from a binary not signed by Docker timed out after 5 seconds while the prompt was still open, and fell back to the Docker CLI credentials.Authorizethat time only once the engine has answered a version request within 1 second, so an engine that hangs falls back after 1 second. Builds signed by Docker get no prompt, so for themAuthorizeanswers without waiting on the user.Related issue
No Compose issue. Depends on #14541.
Changes made
registry: authorize docker/auth/** before reading the Docker Desktop session:desktopSessioncallsAuthorize(docker/auth/**). That pattern coversdocker/auth/hub/**,docker/auth/metadata/hub/**, and theirhub-stagingcounterparts, so one decision serves both the production and the staging session.Authorizegets a 1 minute timeout (desktopAuthorizeTimeout), to leave time for the prompt. The session reads keep the 5 seconddesktopLookupTimeout, now applied through their contexts only: the client-wideWithTimeout(5s)is removed, since it would cut the prompt short.secrets.ErrAccessDeniedand anAuthorizeerror is wrapped; both fall back to the Docker CLI credentials and are not retried forretryInterval, like any other failed lookup.registry: wait for the Docker Desktop prompt only when the secrets engine answersandregistry: give the secrets engine version check 1 second:Authorizeis a unary RPC andDecisionis onlyDENYorALLOW.Authorize,desktopSessioncallsVersion(desktopHub.Ping) within the 1 seconddesktopPingTimeout. Only if it answers doesAuthorizeget the 1 minutedesktopAuthorizeTimeout.Versionis not gated by a prompt: it answered in 9.6 ms from a new process, against secrets engine v0.5.0 in Docker Desktop.ConnectErroror a timeout, falls back without callingAuthorizeor reading the session.VersionAuthorize, afterVersionansweredTests: the pattern sent is
docker/auth/**and contains the four Hub realms;PingcallsVersion; authorization and the ping happen once across session refetches; authorization happens again after the decision expires; a denial, an access-denied error, or an unanswered prompt falls back without reading the session; a failed ping falls back without authorizing; the ping gets at most 1 second andAuthorizethe longer timeout; the production timeouts are 1 s, 5 s, and 1 min.Docker Desktop test
A throwaway program, not part of this PR, called
registry.NewDesktopAuthProvideragainst the running Docker Desktop on macOS (darwin/arm64), with a fallback that marks the Docker CLI credentials. It looked updocker.io,index.docker.io,registry-1.docker.io,https://index.docker.io/v1/,dhi.io,registry-1-stage.docker.io, andghcr.io, twice each. Tokens were never printed. The binary is built bygo run, so it is not signed by Docker and Docker Desktop prompts for it.dhi.ioServerAddresshttps://dhi.ioregistry-1-stage.docker.ioghcr.ioThe same program, pointed at a temporary
HOMEso that it did not touch Docker Desktop:Authorizenever calledAuthorizereturned an expiry about 11 hours ahead.Testing done
internal/registry, with-racemake e2e-composeormake e2e-compose-standalonegolangci-lint run ./internal/registry/...(not the fullmake lint)golangci-lint fmt ./internal/registry/...Open items
desktopAuthorizeTimeout? It applies only after the engine has answered a version request, and builds signed by Docker get no prompt, but an engine that answersVersionand then hangs onAuthorizewould still delay the first Docker Hub lookup by up to 1 minute.docker/auth/**the realm to authorize? It also coversdocker/auth/registry/**, which Compose does not read.Authorizeto report that it is waiting for the user, such as a streamed status or a pending decision, would let clients wait for the prompt and fail fast otherwise, instead of relying onVersion.AI tool used (if applicable)
AI Tool: alki, an AI coding agent, running Claude Opus 5.5. It wrote the code changes and the tests, ran the tests and the Docker Desktop test, and wrote this description.